package com.wzcl.app.model.vo;

import com.wzcl.app.dao.model.FileModel;
import com.wzcl.app.model.common.WZCL;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.BeanUtils;

import java.util.Map;

@EqualsAndHashCode(callSuper = false)
@Data
public class FileModelVo extends BaseVo{

    @ApiModelProperty(value = "素材名称")
    private String name;

    @ApiModelProperty(value = "素材描述")
    private String description;

    @ApiModelProperty(value = "类型")
    private Integer type;
    private String typeStr;

    @ApiModelProperty(value = "封面图")
    private String previewImage;

    @ApiModelProperty(value = "内容")
    private String content;

    @ApiModelProperty(value = "所属组别")
    private Integer fileGroupId;

    private FileModelVo(){

    }

    public static FileModelVo create(FileModel fileModel) {
        FileModelVo fileModelVo = new FileModelVo();
        BeanUtils.copyProperties(fileModel,fileModelVo);
        fileModelVo.translationValueStr();
        return fileModelVo;
    }

    @Override
    public void translationValueStr() {
        Map<String, Map<Integer, String>> map = getTranslationMap();
        this.typeStr = map.get(WZCL.GROUP_NAME.FILE_TYPE).get(this.type);
    }

    @Override
    public void processResources() {

    }
}
